<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }
</style>

{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">新增</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform"  form="submit" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">会员昵称 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="nickname" placeholder="请输入会员昵称">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">密码 </label>
                                    <div class="am-u-sm-9">
                                        <input type="password" class="tpl-form-input" name="password" placeholder="请输入密码">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">电子邮箱 </label>
                                    <div class="am-u-sm-9">
                                        <input type="email" class="tpl-form-input" name="email" placeholder="请输入电子邮箱">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">性别 </label>
                                    <div class="am-u-sm-9">
                                        <label> <input type="radio" class="tpl-form-input" value="0" name="sex" checked="checked">保密</label>
                                        <label> <input type="radio" class="tpl-form-input" value="1" name="sex">男</label>
                                        <label> <input type="radio" class="tpl-form-input" value="2" name="sex">女</label>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">会员等级 </label>
                                    <div class="am-u-sm-9">
                                        <div class="am-u-sm-9">
                                            <select data-am-selected="{searchBox: 1}" name="level" style="display: none;">
                                                {foreach name="level" key="k" item="v"}
                                                <option value="{$k}">{$v}</option>
                                                {/foreach}
                                            </select>

                                        </div>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">手机号码 </label>
                                    <div class="am-u-sm-9">
                                        <input type="number" class="tpl-form-input" name="mobile" placeholder="请输入手机号码">
                                        <small></small>
                                    </div>
                        </div>


                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a onclick="javascript:history.back(-1);" ><input class="btn btn-default" type="reset" value="返回">&nbsp;&nbsp;&nbsp;&nbsp;</a>


                                        <input class="btn btn-info" type="submit"  value="提交">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}

<script>

    //提交
    function roleSubmit(){
        var form=document.getElementById("roleform");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('addData')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.href=document.referrer;

                });
            }
        });
        // $.post("{:Url('addData')}", formData, function (res) {
        // if (res.code != 200) {
        //     layer.msg(res.msg, {shade: 0.5, time: 1000,icon: 2});
        //     return false;
        // }
        // layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function () {
        //     // location.reload();
        //     location.href = "{:url('index')}";
        // });
        // });
        // $('#roleform').submit();
    }
</script>

</html>